//------------------------------------------------------------------------
// <copyright file="FileInfoControl.cs" company="DevDir">
//   Copyleft (c) DevDir. No rights reserved.
// </copyright>
// <author>Nikita Sharov</author>
//------------------------------------------------------------------------

namespace DevDir.Mp3.Equilibrist.Controls
{
  using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Drawing;
  using System.Data;
  using System.Text;
  using System.Windows.Forms;  
  
  public partial class FileDataControl : BaseControl
  {
    private BindingSource dataSource;
    
    public FileDataControl()
    {
      this.InitializeComponent();
    }

    public BindingSource DataSource
    {
      get 
      { 
        return this.dataSource; 
      }

      set
      {
        if (this.dataSource != value)
        {
          this.dataSource = value;
          this.OnDataSourceChanged();
        }
      }
    }

    protected virtual void OnDataSourceChanged()
    {
      // TODO: Handle this.
      return;
      
      this.pathTextBox.DataBindings.Add(new Binding("Text",
        this.dataSource, "FilePath", true,
        DataSourceUpdateMode.OnValidation, Settings.NullValue));
      this.fileTextBox.DataBindings.Add(new Binding("Text",
        this.dataSource, "FileName", true,
        DataSourceUpdateMode.OnValidation, Settings.NullValue));

      Binding sizeBinding = new Binding("Text",
        dataSource, "FileSize", true,
        DataSourceUpdateMode.OnValidation, Settings.NullValue);
      sizeBinding.Format += 
        new ConvertEventHandler(this.SizeBindingFormat);
      sizeTextBox.DataBindings.Add(sizeBinding);
    }

    private void SizeBindingFormat(object sender, ConvertEventArgs e)
    {
      e.Value = String.Format("{0:0,0} KB", (long)e.Value);
    }

  }
}
